﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="NClassify" nillable="true" type="NClassifyConfig" />
  <xs:complexType name="NClassifyConfig">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="1" name="settings" type="NClassifySettings" />
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element minOccurs="0" maxOccurs="1" name="value" type="SimpleType" />
        <xs:element minOccurs="0" maxOccurs="1" name="import" type="ImportFile" />
        <xs:element minOccurs="0" maxOccurs="1" name="enum" type="EnumType" />
        <xs:element minOccurs="0" maxOccurs="1" name="service" type="ServiceInfo" />
        <xs:element minOccurs="0" maxOccurs="1" name="message" type="ComplexType" />
      </xs:choice>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="NClassifySettings">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="1" name="namespace" type="xs:string" />
      <xs:element minOccurs="0" maxOccurs="1" name="xml-defaults" type="XmlDefaults" />
    </xs:sequence>
    <xs:attribute name="src" type="xs:string" />
  </xs:complexType>
  <xs:complexType name="XmlDefaults">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="unbounded" name="formatting" type="FormatInfo" />
    </xs:sequence>
    <xs:attribute name="namespace-uri" type="xs:string" />
    <xs:attribute default="element" name="form" type="XmlAttributeType" />
    <xs:attribute default="false" name="ignore-empty" type="xs:boolean" />
  </xs:complexType>
  <xs:complexType name="FormatInfo">
    <xs:attribute name="type" type="FieldType" use="required" />
    <xs:attribute name="format" type="xs:string" />
    <xs:attribute default="invariant" name="culture" type="CultureInfo" />
    <xs:attribute default="false" name="ignore-empty" type="xs:boolean" />
  </xs:complexType>
  <xs:simpleType name="FieldType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="bool" />
      <xs:enumeration value="bytes" />
      <xs:enumeration value="int8" />
      <xs:enumeration value="uint8" />
      <xs:enumeration value="int16" />
      <xs:enumeration value="uint16" />
      <xs:enumeration value="int32" />
      <xs:enumeration value="uint32" />
      <xs:enumeration value="int64" />
      <xs:enumeration value="uint64" />
      <xs:enumeration value="float" />
      <xs:enumeration value="double" />
      <xs:enumeration value="guid" />
      <xs:enumeration value="dateTime" />
      <xs:enumeration value="timeSpan" />
      <xs:enumeration value="string" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="CultureInfo">
    <xs:restriction base="xs:string">
      <xs:enumeration value="invariant" />
      <xs:enumeration value="current" />
      <xs:enumeration value="current-ui" />
      <xs:enumeration value="installed-ui" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="XmlAttributeType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="ignore" />
      <xs:enumeration value="element" />
      <xs:enumeration value="attribute" />
      <xs:enumeration value="text" />
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="SimpleType">
    <xs:complexContent mixed="false">
      <xs:extension base="BaseType">
        <xs:sequence>
          <xs:element minOccurs="0" maxOccurs="1" name="validation" type="ArrayOfChoice1" />
        </xs:sequence>
        <xs:attribute name="base" type="FieldType" use="required" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="BaseType" abstract="true">
    <xs:complexContent mixed="false">
      <xs:extension base="RootItem">
        <xs:attribute name="name" type="xs:NCName" />
        <xs:attribute name="access" type="FieldAccess" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="RootItem" abstract="true" />
  <xs:complexType name="ImportFile">
    <xs:complexContent mixed="false">
      <xs:extension base="RootItem">
        <xs:attribute name="file" type="xs:anyURI" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:simpleType name="FieldAccess">
    <xs:restriction base="xs:string">
      <xs:enumeration value="public" />
      <xs:enumeration value="private" />
      <xs:enumeration value="protected" />
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="ComplexType">
    <xs:complexContent mixed="false">
      <xs:extension base="BaseType">
        <xs:sequence>
          <xs:element minOccurs="0" maxOccurs="1" name="implements" type="ArrayOfString" />
          <xs:element minOccurs="0" maxOccurs="1" name="fields" type="ArrayOfChoice3" />
          <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element minOccurs="0" maxOccurs="1" name="value" type="SimpleType" />
            <xs:element minOccurs="0" maxOccurs="1" name="enum" type="EnumType" />
            <xs:element minOccurs="0" maxOccurs="1" name="message" type="ComplexType" />
          </xs:choice>
        </xs:sequence>
        <xs:attribute name="inherits" type="xs:NCName" />
        <xs:attribute default="all" name="generate" type="CodeGeneration" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="ArrayOfString">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="unbounded" name="interface" nillable="true" type="xs:string" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="ArrayOfChoice3">
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:element minOccurs="1" maxOccurs="1" name="message" nillable="true" type="ComplexTypeRef" />
      <xs:element minOccurs="1" maxOccurs="1" name="primitive" nillable="true" type="Primitive" />
      <xs:element minOccurs="1" maxOccurs="1" name="enum" nillable="true" type="EnumTypeRef" />
      <xs:element minOccurs="1" maxOccurs="1" name="value" nillable="true" type="SimpleTypeRef" />
    </xs:choice>
  </xs:complexType>
  <xs:complexType name="ComplexTypeRef">
    <xs:complexContent mixed="false">
      <xs:extension base="FieldInfo">
        <xs:attribute name="type" type="xs:NCName" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="FieldInfo" abstract="true">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="1" name="xml-options" type="XmlFieldOptions" />
    </xs:sequence>
    <xs:attribute name="default" type="xs:string" />
    <xs:attribute name="name" type="xs:NCName" />
    <xs:attribute name="property" type="xs:NCName" />
    <xs:attribute name="ordinal" type="xs:unsignedInt" use="required" />
    <xs:attribute default="public" name="access" type="FieldAccess" />
    <xs:attribute default="false" name="array" type="xs:boolean" />
    <xs:attribute default="read-write" name="direction" type="FieldDirection" />
    <xs:attribute default="optional" name="use" type="FieldUse" />
  </xs:complexType>
  <xs:complexType name="XmlFieldOptions">
    <xs:attribute name="form" type="XmlAttributeType" />
    <xs:attribute name="name" type="xs:NCName" />
    <xs:attribute name="array-item-name" type="xs:NCName" />
    <xs:attribute name="format" type="xs:string" />
    <xs:attribute name="culture" type="CultureInfo" />
    <xs:attribute default="false" name="ignore-empty" type="xs:boolean" />
  </xs:complexType>
  <xs:simpleType name="FieldDirection">
    <xs:restriction base="xs:string">
      <xs:enumeration value="read-write" />
      <xs:enumeration value="read-only" />
      <xs:enumeration value="write-only" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="FieldUse">
    <xs:list>
      <xs:simpleType>
        <xs:restriction base="xs:string">
          <xs:enumeration value="optional" />
          <xs:enumeration value="required" />
          <xs:enumeration value="obsolete" />
          <xs:enumeration value="prohibited" />
        </xs:restriction>
      </xs:simpleType>
    </xs:list>
  </xs:simpleType>
  <xs:complexType name="SimpleTypeRef">
    <xs:complexContent mixed="false">
      <xs:extension base="FieldInfo">
        <xs:attribute name="type" type="xs:NCName" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="Primitive">
    <xs:complexContent mixed="false">
      <xs:extension base="FieldInfo">
        <xs:sequence>
          <xs:element minOccurs="0" maxOccurs="1" name="validation" type="ArrayOfChoice2" />
        </xs:sequence>
        <xs:attribute name="type" type="FieldType" use="required" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="ArrayOfChoice2">
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:element minOccurs="1" maxOccurs="1" name="length" nillable="true" type="LengthConstraint" />
      <xs:element minOccurs="1" maxOccurs="1" name="range" nillable="true" type="RangeConstraint" />
      <xs:element minOccurs="1" maxOccurs="1" name="match" nillable="true" type="MatchConstraint" />
      <xs:element minOccurs="1" maxOccurs="1" name="code" nillable="true" type="CodedConstraint" />
      <xs:element minOccurs="1" maxOccurs="1" name="predefined" nillable="true" type="PredefinedValue" />
    </xs:choice>
  </xs:complexType>
  <xs:complexType name="LengthConstraint">
    <xs:complexContent mixed="false">
      <xs:extension base="ValidationRule">
        <xs:attribute default="0" name="min" type="xs:unsignedInt" />
        <xs:attribute default="4294967295" name="max" type="xs:unsignedInt" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="ValidationRule" abstract="true" />
  <xs:complexType name="CodedConstraint">
    <xs:complexContent mixed="false">
      <xs:extension base="ValidationRule">
        <xs:sequence>
          <xs:element minOccurs="0" maxOccurs="1" name="method" type="xs:string" />
        </xs:sequence>
        <xs:attribute name="language" type="GeneratorLanguage" use="required" />
        <xs:attribute name="test" type="xs:string" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:simpleType name="GeneratorLanguage">
    <xs:restriction base="xs:string">
      <xs:enumeration value="C#" />
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="PredefinedValue">
    <xs:complexContent mixed="false">
      <xs:extension base="ValidationRule">
        <xs:sequence>
          <xs:element minOccurs="0" maxOccurs="unbounded" name="value" type="xs:string" />
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="MatchConstraint">
    <xs:complexContent mixed="false">
      <xs:extension base="ValidationRule">
        <xs:attribute default=".*" name="pattern" type="xs:string" />
        <xs:attribute default="false" name="ignoreCase" type="xs:boolean" />
        <xs:attribute default="false" name="multiline" type="xs:boolean" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="RangeConstraint">
    <xs:complexContent mixed="false">
      <xs:extension base="ValidationRule">
        <xs:attribute name="min" type="xs:string" />
        <xs:attribute name="max" type="xs:string" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="EnumTypeRef">
    <xs:complexContent mixed="false">
      <xs:extension base="FieldInfo">
        <xs:attribute name="type" type="xs:NCName" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="EnumType">
    <xs:complexContent mixed="false">
      <xs:extension base="BaseType">
        <xs:sequence>
          <xs:element minOccurs="0" maxOccurs="unbounded" name="value" type="Item" />
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="Item">
    <xs:attribute name="name" type="xs:NCName" />
    <xs:attribute name="ordinal" type="xs:unsignedInt" use="required" />
  </xs:complexType>
  <xs:simpleType name="CodeGeneration">
    <xs:restriction base="xs:string">
      <xs:enumeration value="all" />
      <xs:enumeration value="interface-only" />
      <xs:enumeration value="class-only" />
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="ServiceInfo">
    <xs:complexContent mixed="false">
      <xs:extension base="BaseType">
        <xs:sequence>
          <xs:element minOccurs="0" maxOccurs="unbounded" name="method" type="ServiceMethod" />
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="ServiceMethod">
    <xs:attribute name="name" type="xs:NCName" />
    <xs:attribute name="returns" type="xs:NCName" />
    <xs:attribute name="argument" type="xs:NCName" />
  </xs:complexType>
  <xs:complexType name="ArrayOfChoice1">
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:element minOccurs="1" maxOccurs="1" name="predefined" nillable="true" type="PredefinedValue" />
      <xs:element minOccurs="1" maxOccurs="1" name="length" nillable="true" type="LengthConstraint" />
      <xs:element minOccurs="1" maxOccurs="1" name="range" nillable="true" type="RangeConstraint" />
      <xs:element minOccurs="1" maxOccurs="1" name="match" nillable="true" type="MatchConstraint" />
      <xs:element minOccurs="1" maxOccurs="1" name="code" nillable="true" type="CodedConstraint" />
    </xs:choice>
  </xs:complexType>
</xs:schema>